/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package net.worlds;

import net.worlds.object.GameObject;
import net.worlds.object.Part;
import org.jbox2d.common.Vec2D;


public class TransformDef {
    public int id;
    public Vec2D pos;
    public float rotation;
    public Vec2D vel;
    public float rvel;
    public int hash;
    public void exec()
    {
        GameObject obj = Main.getGame().getByID(id);
        if(obj instanceof Part && obj.isInWorld())
        {
            Part p = (Part)obj;
            if(pos != null)
            {
                if(((Part)p).getBody().hash() == hash)
                {
                    if(p.isRemoteCharacter)
                        ((Part)p).setTargetPoint(pos);
                    else
                        ((Part)p).getBody().setXForm(pos, (float) rotation);
                }
            }
            if(vel != null)
            {
                if(((Part)p).getBody().hash() == hash)
                {
                    ((Part)p).getBody().setLinearVelocity(vel);
                    ((Part)p).getBody().setAngularVelocity((float) rvel);
                }
            }
        }
    }
}
